<!--
 * @Author: your name
 * @Date: 2020-05-17 10:57:05
 * @LastEditTime: 2020-05-17 11:24:06
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \suqian_zhcg_zhjgpt\src\views\components\common\HeaderTab.vue
-->
<template>
  <section class="header-tab">
    <section class="item" :class="current.code === item.code ? 'item-active' : ''"
             v-for="(item, index) in data"
             :key="index"
             @click="tabClick(item)">
      {{item.label}}
    </section>
  </section>
</template>

<script>
  export default {
    name: 'HeaderTab',
    props: {
      data: {
        type: Array,
        default: () => {
          return [
            {label: '环卫管理', code: 'hw'},
            {label: '渣土管理', code: 'zt'},
            {label: '路灯管理', code: 'ld'},
            {label: '公共自行车管理', code: 'ggzxc'},
            {label: '公共停车场管理', code: 'ggtcc'},
            {label: '综合执法', code: 'zf'}
          ]
        }
      }
    },
    data() {
      return {
        current: {}
      }
    },
    mounted() {
      this.tabClick(this.data[0])
    },
    methods: {
      tabClick(item) {
        if (this.current.code !== item.code) {
          this.current = item
          this.$emit('change', this.current)
        }
      }
    }
  }
</script>

<style scoped>
.header-tab {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}
.header-tab .item {
  width: 1.31rem;
  height: .35rem;
  line-height: .35rem;
  margin: 0 .1rem;
  background: url("~@/assets/image/base/tab_default.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;

  cursor: pointer;

  font-family: FZZongYi-M05;
  font-size: .16rem;
  font-weight: bold;
  font-style:italic;
  color: #FFF;
}
.header-tab .item-active {
  background: url("~@/assets/image/base/tab_active.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

</style>
